package cn.cn.tedu.file;

import java.io.*;

/**
 * @author ：Dsi
 * @date ：2021/11/16 11:12
 * Describe ：该类用于测试字符输入流
 */
public class TestIn2 {
    public static void main(String[] args) {
        method1();//高效
        //method2();//普通
    }

    private static void method1() {
        BufferedReader br = null;
        try {

            br = new BufferedReader(new FileReader("D:\\ready\\1.txt"));
            int c;
            while ((c = br.read()) != -1) {
                System.out.println(c);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                br.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    private static void method2() {
        Reader r = null;
        try {
            r = new FileReader("D:\\ready\\1.txt");
            int a;
            while ((a = r.read()) != -1) {
                System.out.println(a);
            }
        } catch (Throwable e) {
            e.printStackTrace();
        } finally {
            try {
                r.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

}
